package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.MessageData;
import com.thinkcube.edutainment.service.viewitem.NotificationItem;
import com.thinkcube.edutainment.service.viewitem.NotificationItem_;
@EBean
public class NotificationAdapter extends BaseAdapter {
	
	@RootContext
	Context context;
	
	List<MessageData> notificationData;

	@Override
	public int getCount() {
		
		return notificationData.size();
	}

	public List<MessageData> getNotificationData() {
		return notificationData;
	}

	public void setNotificationData(List<MessageData> notificationData) {
		this.notificationData = notificationData;
	}

	@Override
	public MessageData getItem(int position) {
		
		return notificationData.get(position);
	}

	@Override
	public long getItemId(int position) {
		
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		NotificationItem notificationItem;
		if (convertView == null) {
			notificationItem = NotificationItem_.build(context);
		} else {
			notificationItem = (NotificationItem) convertView;
		}

		notificationItem.bind(getItem(position));

		return notificationItem;
	}

}
